<template>
  <div>
    <router-view style="margin-bottom:80px"></router-view>
    <!-- 医生端 -->
    <van-tabbar route v-if="userInfo.userType == 0 && isTabbar" active-color="#42DDA2">
      <van-tabbar-item replace to="/home" icon="wap-home">首页</van-tabbar-item>
      <van-tabbar-item replace to="/doctorDataAnalysis" icon="chart-trending-o">数据分析</van-tabbar-item>
      <van-tabbar-item replace to="/doctorPerson" icon="manager">我的</van-tabbar-item>
    </van-tabbar>
    <!-- 患者端 -->
    <van-tabbar route v-if="userInfo.userType == 1 && isTabbar" active-color="#42DDA2">
      <van-tabbar-item replace to="/patientHome" icon="wap-home">首页</van-tabbar-item>
      <van-tabbar-item replace to="/patientDataAnalysis" icon="chart-trending-o">数据分析</van-tabbar-item>
      <van-tabbar-item replace to="/patientPerson" icon="manager">我的</van-tabbar-item>
    </van-tabbar>
  </div>
</template>
<script>
// 引入接口
import { getUserInfo } from '@/api/index.js'
// import { getUrlParam } from '@/utils/common'

export default {
  name: 'App',
  data() {
    return {
      bg: true,
      isTabbar: true,
      userInfo: ''
    }
  },
  watch: {
    $route(to, from) {
      console.log('to', to.meta.isTabbar, from)
      this.isTabbar = to.meta.isTabbar
    },
  },
  created() {
    if (window.location.href.indexOf('share=0') != -1) {
      this.phoneBase64 = window.location.hash.split('p=')[1].split('&share=0')[0]; // 正式
    } else {
      this.phoneBase64 = window.location.search.split('p=')[1]; // 正式
    }
    // this.phoneBase64 = 'MTU4MjczOTYwNTU='; // 患者
    // this.phoneBase64 = 'MTMxOTAzNDY3NTU='; // 医生
    this.getUserInfoFunc();
  },
  mounted(){
  },
  methods: {
    // 获取用户信息
    getUserInfoFunc() {
      getUserInfo("phoneBase64="+this.phoneBase64).then(res => {
        console.log('res', res.data)
        this.userInfo =  res.data;
        sessionStorage.setItem('userInfo', JSON.stringify(res.data))
      }).catch(error => {
        console.log('error', error)
      })
    }
  }
}
</script>

<style>
@import './common/font/font.css';

#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* margin-top: 20px; */
}

.flex {
  display: flex;
  display: -webkit-flex;
}

.flex-between {
  justify-content: space-between;
}

.flex-left {
  justify-content: flex-start;
}

.flex-right {
  justify-content: flex-end;
}

.flex-around {
  justify-content: space-around;
}

.align-end {
  align-items: flex-end;
}

.flex-wrap {
  flex-wrap: wrap;
}

.flex-center {
  justify-content: center;
}

.align-center {
  align-items: center;
}

.flex-column {
  flex-direction: column;
}
</style>
